﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;

namespace map.member.lvyou
{
    public partial class newzhekou : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GridViewBind();
        }
        private void GridViewBind()
        {
            RuleCode.Table.lyzhekou x = RuleCode.Table.lyzhekou.Find("cbuserid = '" + AliApi.appUserId + " '");
            this.GridView1.DataSource = x.MyTable;
            this.GridView1.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            lyzhekou zk = lyzhekou.Find(" 1=2 ");
            zk.New();
            zk.cbuserid = AliApi.appUserId;
            zk.lyplacekeword = keyword.Text;
            zk.num = Convert.ToInt32(count.Text);
            zk.jcdesc2 = desp.Value;

            zk.jccreatedate = DateTime.Now;
            zk.jcvaliddate = Convert.ToDateTime(validdate.Text);
            zk.jcvalidtime = Convert.ToInt32(validtime.Text);
            zk.Insert();
            GridViewBind();



        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            lyzhekou zk = lyzhekou.Find(" recid ='" + Label_recid.Text + "'", "RECID");
            zk.lyplacekeword = keyword.Text;
            zk.num = Convert.ToInt32(count.Text);
            zk.jccreatedate = DateTime.Now;
            zk.jcdesc2 = desp.Value;
            zk.jcvaliddate = Convert.ToDateTime(validdate.Text);
            zk.jcvalidtime = Convert.ToInt32(validtime.Text);
            zk.Modify();
            GridViewBind();
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
        }

        protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {

            lyzhekou z = new lyzhekou();
            string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
            lyzhekou uc = lyzhekou.Find(" recid = '" + id + "'", "RECID");

            Label_recid.Text = uc.RECID.ToString();
            keyword.Text = uc.lyplacekeword.ToString();
            count.Text = uc.num.StringValue;
            validdate.Text = uc.jcvaliddate.StringValue;
            validtime.Text = uc.jcvalidtime.StringValue;
            desp.Value = Server.HtmlDecode(uc.jcdesc2.StringValue);

        }

        protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
        {

        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
            lyzhekou uc = lyzhekou.Find(" recid = '" + id + "'", "RECID");
            uc.Delete();
            GridViewBind();

        }
    }
}
